<script>
    document.getElementById('demo').onclick=function(){
        console.log('单击');
    };
    </script>
    <div id="demo">单击</div>
    //第一种修改
    <div id="demo">单击1</div>
    <script>
        document.getElementById('demo').onclick=function(){
            console.log('单击');
        };
        </script>
  //第二种修改
  <script>
      window.onload=function(){
          //JavaScript代码
      };
    document.getElementById('demo').onclick=function(){
        console.log('单击');
    };
    </script>
    <div id="demo">单击2</div>
    

        
